#pragma once
#include <cstdarg>
#include <cstring>
#include <cstdio>
#include <ctime>

enum LEVEL
{
    TEST,
    NORMAL,
    WARNING,
    ERROR,
    FATAL
};

static const char *lvtable[] = {"TEST", "NORMAL", "WARNING", "ERROR", "FATAL"};
static const char *filepath = "./log.txt";

static void LogMessage(LEVEL level, const char *format, ...)
{
#ifndef DEBUG
    if (level == TEST)
        return;
#endif
    char buffer[1024];
    snprintf(buffer, sizeof(buffer), "[%ld] %s:", time(nullptr), lvtable[level]);
    va_list ap;
    va_start(ap, format);
    vsnprintf(buffer + strlen(buffer), sizeof(buffer) - strlen(buffer), format, ap);
    va_end(ap);
    printf("%s\n", buffer);
    // FILE *fp = fopen(filepath, "a");
    // fprintf(fp, "%s\n", buffer);
}